<template>
	<om-formsub-outer :index="index" :checkedit="checkedit">
		<om-autoform ref="autoform" :checkedit="checkedit" :initConfigData="autoformdata" :initValue="initValue"></om-autoform>
	</om-formsub-outer>
</template>

<script>
	import {buildSubFormData,subOnLoad, formValidation, changeEditor,configSelectData} from '../../../static/js/formUtil.js';
	import { ignoreHtml,ptFloat,minusF,sumF, getDateStr, errorModal,getDateTimeStr, confirmModal} from '@/static/js/common.js';
	export default {
		provide() {
			return {
				formPage: this
			};
		},
		data() {
			return buildSubFormData({
				initValue:{
					posId: "",
					instId: "",
					fileList:[]//上次保存的文件列表
				},
				formdata:{
					startTime: '',
					endTime: ''
				},
				businessformCacheKey:'fin-bx-expensesReimbursement-data-info-businessform-cache',
				instCacheKey:'fin-bx-expensesReimbursement-data-info-inst-cache',
				bxUserId:'',
				bxUserName:'',
				expenseCategoryId:'',
				expenseCategoryName:'',
				codeMap: {},
				dvid:'',
				posId:'',
				posName:'',
				instId: '',
				instName: '',
				invoiceNumber: '',
				payApplicationFormDataShowId: '',
				filterIdList: [],
				serverDate: '',
				marketingPlanningProductCache:'fin-bx-expenses-data-info-marketingPlanningProduct-cache',
				feesAggregatedWayCache:'fin-bx-expenses-data-info-feesAggregatedWay-cache',
				feesAggregatedWayCodeCacheKey:'fin-bx-expensesReimbursement-data-info-feesAggregatedWayCode-cache',
				researchDevelopmentIdCacheKey:'fin-bx-expensesReimbursement-data-info-researchDevelopmentId-cache',
				businessOpportunityIdCacheKey:'fin-bx-expensesReimbursement-data-info-businessOpportunityId-cache',
				saleOrderIdCacheKey:'fin-bx-expensesReimbursement-data-info-saleOrderId-cache',
				newProductIdCacheKey:'fin-bx-expensesReimbursement-data-info-newProductId-cache',
				payApplicationFormDataShowIdCacheKey:'fin-bx-expensesReimbursement-data-info-payApplicationFormDataShowId-cache',
				userIdCacheKey:'fin-bx-expensesReimbursement-data-info-userId-cache',
				partakeUserCache:'fin-bx-expenses-data-info-fpartakeUser-cache',
				erpProjectBatches:'',
				setData:{
					partakeInstId:'',
					partakeInstName:'',
					feesAggregatedWayIds:'',
					feesAggregatedWayName:''
				}
			})
		},
		methods: {
			verifyPartakeUser(){
				let _that = this
				if(!_that.$refs.autoform.formdata.partakeInstId){
					let title1 = _that.$refs.autoform.getEditorTitle("title2")
					let title2 = _that.$refs.autoform.getEditorTitle("title2","partakeInstId")
					errorModal(_that,'提示信息',title1+'的'+title2+'需要优先完成编辑!',()=>{
						return false
					})
				}else{
					_that.$refs.autoform.changeEditor("title2","partakeUserId",{
						"link":'../../public/search/search',
						"linkParam":{
							other:JSON.stringify({
								instId:_that.$refs.autoform.formdata.partakeInstId
							}),
							url:'orgInstPosUserOfficial/getUserListByInstPosId',
							initload:true,
							namefield:'username',
							cachename:_that.partakeUserCache
						}
					})
					return true
				}
			},
			inputApplyPayNum(value){
				let _that = this
				_that.$refs.autoform.formdata.selfPayNum = value
			},
			getReimbursedBasedExpensePerson(expenseTypeId){
				let _that = this
				_that.om.request(
					"reimbursementCriteria/getReimbursedBasedExpensePerson",
					{
						expenseTypeId:expenseTypeId,
						userId: _that.bxUserId
					}
				).then(res=>{
					_that.$refs.autoform.formdata.reimbursementCriteriaId = res.value.reimbursementCriteriaId
					_that.$refs.autoform.formdata.reimbursementStandardId = res.value.reimbursementStandardId
					if(res.value.reimbursementStandards){
						_that.$refs.autoform.formdata.reimbursementStandards = res.value.reimbursementStandards
					}else{
						_that.$refs.autoform.clear("title2","reimbursementStandardId")
						_that.$refs.autoform.clear("title2","calculateAmount")
					}
				})
			},
			clearFeesAggregatedWayCode(){
				let _that = this
				_that.$refs.autoform.clear('title2', 'feesAggregatedWayCode');
				_that.$refs.autoform.changeEditor("title2", "partakeUserId", "required", false)
			},
			verifyNum(num, planPayNum, applyPayNum){
				let _that = this;
				if (!planPayNum) {
				    planPayNum = _that.$refs.autoform.formdata.planPayNum
				}
				let paidNum = _that.$refs.autoform.formdata.paidNum
				if (!applyPayNum) {
				    applyPayNum = _that.$refs.autoform.formdata.applyPayNum
				}
				if(paidNum > Number(planPayNum)){
					confirmModal(_that, '提示信息', '票据金额不能小于已付款金额', () => {
						if(num == 1){
							_that.$refs.autoform.formdata.planPayNum = ''
						}else{
							_that.$refs.autoform.formdata.applyPayNum = ''
							_that.$refs.autoform.formdata.selfPayNum = ''
						}
					})
					return false
				}else{ 
					let subNum = minusF(planPayNum, paidNum)
					if(num == 1){
						_that.$refs.autoform.formdata.applyPayNum = subNum
						_that.$refs.autoform.formdata.selfPayNum = subNum
					}
				}
				return true
			},
			onInputPlanPayNum(item){
				let _that = this;
				if (item) {
				    _that.verifyNum(1,item)
				}
			},
			clearPlanPayNum(){
				let _that = this
				_that.$refs.autoform.clear("title2","applyPayNum")
				_that.$refs.autoform.clear("title2","selfPayNum")
				_that.$refs.autoform.clear("title2","planPayNum")
			},
			onInputApplyPayNum(item){
				let _that = this;
				if (item) {
				    if (_that.verifyNum(2,'',item)) {
				        _that.$refs.autoform.formdata.selfPayNum = item
				    }
				}
			},
			clearPaidNum(){
				let _that = this
				_that.$refs.autoform.clear("title2","paidNum")
				_that.onInputPaidNum(0)
			},
			onInputPaidNum(val){
				let _that = this;
				let planPayNum = Number(_that.$refs.autoform.formdata.planPayNum)
				let paidNum = Number(val)
				let title = _that.$refs.autoform.getEditorTitle("title2","planPayNum")
				let title1 = _that.$refs.autoform.getEditorTitle("title2","paidNum")
				if(paidNum  > planPayNum){
					confirmModal(_that, '提示信息', title1+'不能大于'+title, () => {
						_that.$refs.autoform.clear("title2","paidNum")
					})
				}else{
					let num = planPayNum - paidNum
					_that.$refs.autoform.formdata.applyPayNum = num
					_that.$refs.autoform.formdata.selfPayNum = num
				}
			},
			onInputSelfPayNum(item){
				let _that = this;
				let applyPayNum = _that.$refs.autoform.formdata.applyPayNum
				if(Number(item) > Number(applyPayNum)){
					confirmModal(_that, '提示信息', '核准报销金额不能大于申请报销金额', () => {
						_that.$refs.autoform.formdata.selfPayNum = ''
					})
				}
			},
			clearnApplyPayNum(){
				let _that = this;
				_that.$refs.autoform.clear("title2","applyPayNum")
				_that.$refs.autoform.clear("title2","selfPayNum")
			},
			clearUserId(){
				let _that = this;
				_that.$refs.autoform.clear("title2","userId")
				_that.$refs.autoform.clear("title2","posId")
				_that.$refs.autoform.clear("title2","instId")
				_that.$refs.autoform.clear("title2","partakeInstId")
			},
			onchangeInvoiceDate(item){
				let _that = this;
				if(item){
					if(!_that.$refs.autoform.formdata.userId){
						_that.$refs.autoform.formdata.userId = _that.bxUserId
						_that.$refs.autoform.formdata.userName = _that.bxUserName
						_that.$refs.autoform.formdata.posId = _that.posId
						_that.$refs.autoform.formdata.posName = _that.postName
						_that.$refs.autoform.formdata.instId = _that.instId
						_that.$refs.autoform.formdata.instName = _that.instName
						_that.$refs.autoform.formdata.partakeInstId = _that.instId
						_that.$refs.autoform.formdata.partakeInstName = _that.instName
					}
				}
			},
			clearPayApplicationForm(){
				let _that = this;
				_that.payApplicationFormDataShowId = ''
				_that.$refs.autoform.clear('title2', 'payApplicationFormDataShowId');
				_that.$refs.autoform.changeEditor("title2", "paidNum","type","numberbox")
				_that.$refs.autoform.clear('title2', 'userId');
				_that.$refs.autoform.clear('title2', 'posId');
				_that.$refs.autoform.clear('title2', 'instId');
				_that.$refs.autoform.clear('title2', 'remark');
				_that.$refs.autoform.clear('title2', 'paidNum');
				_that.$refs.autoform.clear('title2', 'payeeName');
				_that.$refs.autoform.clear('title2', 'invoiceDate');
				_that.$refs.autoform.clear('title2', 'partakeInstId');
				_that.$refs.autoform.clear('title2', 'planPayNum');
				_that.$refs.autoform.clear('title2', 'selfPayNum');
				_that.$refs.autoform.clear('title2', 'taxRate');
				_that.$refs.autoform.clear('title2', 'itemCode');
				_that.$refs.autoform.clear('title2', 'itemName');
				_that.$refs.autoform.clear('title2', 'itemType');
				_that.$refs.autoform.clear('title2', 'accountId');
				_that.$refs.autoform.clear('title2', 'accountCode');
				_that.$refs.autoform.clear('title2', 'accountParentId');
			},
			fliterChinese(str) {
			    let temp = "";
			    for (let i = 0; i < str.length; i++)
			        if (str.charCodeAt(i) > 0 && str.charCodeAt(i) < 255)
			            temp += str.charAt(i);
			    return temp;
			},
			onInputInvoiceNumber(item){
				let _that = this;
				if(item){
					var str = _that.fliterChinese(item);
					if (str != item) {
						_that.$refs.autoform.formdata.invoiceNumber = str
						_that.invoiceNumber = str
					}
				}else{
					_that.invoiceNumber = ''
					_that.payApplicationFormDataShowId = ''
					_that.$refs.autoform.clear('title2', 'payApplicationFormDataShowId');
					_that.$refs.autoform.changeEditor("title2", "paidNum","type","numberbox")
				}
			},
			clearInvoiceNumber(){
				let _that = this;
				_that.invoiceNumber = ''
				_that.payApplicationFormDataShowId = ''
				_that.$refs.autoform.clear('title2', 'invoiceNumber');
				_that.$refs.autoform.clear('title2', 'payApplicationFormDataShowId');
				_that.$refs.autoform.changeEditor("title2", "paidNum","type","numberbox")
			},
			clearPartakeInstId(){
				let _that = this
				_that.$refs.autoform.clear('title2', 'partakeInstId');
				_that.$refs.autoform.clear('title2', 'feesAggregatedWayCode');
				_that.$refs.autoform.changeEditor("title2", "feesAggregatedWayCode","type","labelbox")
				_that.$refs.autoform.changeEditor("title2", "partakeUserId", "required", false)
			},
			clearResearchDevelopmentId(){
				let _that = this
				_that.$refs.autoform.clear('title2', 'researchDevelopmentId');
				_that.$refs.autoform.clear('title2', 'researchDevelopmentCode');
			},
			clearBusinessOpportunityId(){
				let _that = this
				_that.$refs.autoform.clear('title2', 'businessOpportunityId');
				_that.$refs.autoform.clear('title2', 'businessOpportunityCode');
			},
			onSelectGetExpenseByParent(item){
				let _that = this
				let formdata = _that.$refs.autoform.formdata
				formdata.expenseTypeId = item.id
				formdata.expenseTypeName = item.typeName
				formdata.expenseTypeCode = item.typeCode
					_that.getReimbursedBasedExpensePerson(item.expenseTypeId)
				formdata.expenseCategoryId = _that.expenseCategoryId
				formdata.expenseCategoryName = _that.expenseCategoryName
				_that.om.request('expenseCategory/getLevel1AccountDictByExpense', {
					expenseCategoryId: item.id					
				}).then(res => {
					if(res.succeed){
						formdata.levelOneAccountId = res.value.id
						formdata.levelOneAccountName = res.value.dicname
						formdata.levelOneAccountCode = res.value.code
					}
				});
				_that.om.request('expenseCategory/getAccountByExpensePosition', {
					expenseCategoryId: item.id,
					postId: '',
				}).then(res => {
					if(res.succeed){
						formdata.budgetLevelOneAccountId = res.value.budgetAccountDictId
						formdata.budgetLevelOneAccountName = res.value.budgetAccountDictName
						formdata.budgetLevelTwoAccountId = res.value.budgetSubAccountDictId
						formdata.budgetLevelTwoAccountName = res.value.budgetSubAccountDictName
					}
				});
			},
			clearGetExpenseByParent(){
				let _that = this
				_that.$refs.autoform.clear('title2', 'expenseTypeId');
				_that.$refs.autoform.clear('title2', 'expenseTypeCode');
				_that.$refs.autoform.clear('title2', 'expenseCategoryId');
				_that.$refs.autoform.clear('title2', 'levelOneAccountId');
				_that.$refs.autoform.clear('title2', 'levelOneAccountCode');
				_that.$refs.autoform.clear('title2', 'budgetLevelOneAccountId');
				_that.$refs.autoform.clear('title2', 'budgetLevelTwoAccountName');
				_that.$refs.autoform.clear('title2', 'reimbursementStandardId');
				_that.$refs.autoform.clear('title2', 'calculateAmount');
			},
			clearBusinessTravel(){
				let formdata = this.$refs.autoform.formdata
				formdata.businessTravelId = "";
				formdata.businessTravelDataId = "";
				formdata.businessTravelCode = "";
				formdata.planStartTime = "";
				formdata.planEndTime = "";
				formdata.startTime = "";
				formdata.endTime = "";
				formdata.cityName = "";
				formdata.address = "";
				formdata.remark = "";
				formdata.sumCosts = "";
				formdata.companions = "";
				formdata.voucherNum = "";
				formdata.taxRate = "";
				formdata.partakeInstId = "";
				formdata.partakeInstName = "";
				formdata.dayNum = "";
				formdata.invoiceNumber = "";
				formdata.vehicleTypeId = "";
				formdata.vehicleTypeName = "";
			},
			onSelectAccount(account){
				this.$refs.autoform.formdata.accountCode = account.code;
				if(account.layerNum == 1) {
					this.$refs.autoform.formdata.accountParentId = account.id;
					this.$refs.autoform.formdata.accountParentName = account.dicname;
				}else{
					let _that = this
					_that.om.request("accountDict/findLevel1Account",{
						accountDictId: account.id
					}).then(res=>{
						if(res.succeed){
							var value = res.value
							_that.$refs.autoform.formdata.accountParentId = value.id;
							_that.$refs.autoform.formdata.accountParentName = value.dicname;
						}else{
							_that.om.toast(res.msg)
						}
					})
				}
			},
			clearAccount(){
				var formdata = this.$refs.autoform.formdata
				this.$refs.autoform.clear("title2", "accountId")					
				formdata.accountCode = ""
				formdata.accountParentId = ""
				formdata.accountParentName = ""
			},
			onSelectStartTime(startTime){
				let _that = this
				let currentTime = getDateTimeStr(new Date())
				let endTime = _that.$refs.autoform.formdata.endTime || currentTime
				if(startTime > endTime){
					_that.om.toast("开始时间不大于当前时间和结束时间")
					_that.$refs.autoform.formdata.startTime = ''
					_that.$refs.autoform.formdata.dayNum = ''
				}
				if(startTime && endTime){
					_that.getDayNumFunc(startTime, endTime)
				}
			},
			onSelectEndTime(endTime){
				let _that = this
				let currentTime = getDateTimeStr(new Date())
				let startTime = _that.$refs.autoform.formdata.startTime
				if(startTime){
					if(endTime < startTime){
						_that.om.toast("结束时间不小于开始时间")
						_that.$refs.autoform.formdata.endTime = ''
						_that.$refs.autoform.formdata.dayNum = ''
					}else if(endTime > currentTime){
						_that.om.toast("结束时间不大于当前时间")
						_that.$refs.autoform.formdata.endTime = ''
						_that.$refs.autoform.formdata.dayNum = ''
					}else{
						_that.getDayNumFunc(startTime, endTime)
					}
				}else if(endTime > currentTime){
					_that.om.toast("结束时间不大于当前时间")
					_that.$refs.autoform.formdata.endTime = ''
					_that.$refs.autoform.formdata.dayNum = ''
				}else{
					_that.getDayNumFunc(startTime, endTime)
				}
			},
			getDayNumFunc(startDate, endDate){
				let _that = this
				_that.om.request('common/getGoOutWorkDayNum', {
					startDate:  startDate,
					endDate: endDate,
				}).then(res => {
					if(res.succeed){
						_that.$refs.autoform.formdata.dayNum = res.value
					}
				});
			},
			verifyStartTime(datetime){
				var currentTime = getDateStr(new Date())
				var endTime = this.formdata.endTime || currentTime
				
				if(datetime > endTime){
					return "开始时间不大于当前时间和结束时间"
				}else{
					return true
				}
			},
			verifyEndTime(datetime){
				var currentTime = getDateStr(new Date())
				var startime = this.formdata.startTime
				if(startime){
					if(datetime < startime){
						return "结束时间不小于开始时间"
					}else if(datetime > currentTime){
						return "结束时间不大于当前时间"
					}else{
						return true
					}
				}else if(datetime > currentTime){
					return "结束时间不大于当前时间"
				}else{
					return true
				}
			},
			initLoad(){
				let _that = this
				//费用类型
				_that.om.request('expenseCategory/getExpenseByParent', {
					id: _that.expenseCategoryId					
				}).then(res => {
					_that.$refs.autoform.changeEditor("title2", "expenseTypeId", "data", configSelectData(res,"id","typeName"))
					_that.$refs.autoform.initSelectIndex("title2", "expenseTypeId")
				});
				
				//会计科目
				// _that.om.request('accountDict/getCombobox', {
				// 	selectInBudget: true					
				// }).then(res => {
				// 	_that.$refs.autoform.changeEditor("title2", "accountId", "data", configSelectData(res,"id","dicname"))
				// 	_that.$refs.autoform.initSelectIndex("title2", "accountId")
				// });
				
				//交通工具
				// _that.om.request('dictZero/getCombobox', {
				// 	code: "37373"					
				// }).then(res => {
				// 	_that.$refs.autoform.changeEditor("title2", "vehicleTypeId", "data", configSelectData(res, "id", "dicname"))
				// 	_that.$refs.autoform.initSelectIndex("title2", "vehicleTypeId")
				// });
				_that.$nextTick(function(){
					// _that.$refs.autoform.initDataTime("title2", "startTime")
					// _that.$refs.autoform.initDataTime("title2", "endTime")
					if(!_that.$refs.autoform.formdata.invoiceDate && _that.serverDate){
						_that.$refs.autoform.formdata.invoiceDate = _that.serverDate
						_that.$refs.autoform.changeEditor("title2", "invoiceDate","max", _that.serverDate)
						if(!_that.$refs.autoform.formdata.userId){
							_that.$refs.autoform.formdata.userId = _that.bxUserId
							_that.$refs.autoform.formdata.userName = _that.bxUserName
							_that.$refs.autoform.formdata.posId = _that.posId
							_that.$refs.autoform.formdata.posName = _that.postName
							_that.$refs.autoform.formdata.instId = _that.instId
							_that.$refs.autoform.formdata.instName = _that.instName
							_that.$refs.autoform.formdata.partakeInstId = _that.instId
							_that.$refs.autoform.formdata.partakeInstName = _that.instName
						}
					}
					if(_that.$refs.autoform.formdata.payApplicationFormDataShowId){
						_that.$refs.autoform.changeEditor("title2", "paidNum","type","labelbox")
					}else{
						_that.$refs.autoform.changeEditor("title2", "paidNum","type","numberbox")
					}

					//承担人
					_that.om.request('orgInstPosUserOfficial/getUserListByInstPosId', {
						instId: _that.$refs.autoform.formdata.partakeInstId || _that.instId					
					}).then(res => {
						_that.$refs.autoform.changeEditor("title2", "partakeUserId", "data", configSelectData(res,"id","username"))
						_that.$refs.autoform.initSelectIndex("title2", "partakeUserId")
					});
				})
			}
		},
		onLoad(e){
			let _that = this
			subOnLoad(_that, e, function() {
				_that.bxUserId = e.bxUserId
				_that.bxUserName = e.bxUserName
				_that.posId = e.posId
				_that.postName = e.posName
				_that.instId = e.instId
				_that.instName = e.instName
				// _that.initValue.partakeInstId = e.instId
				// _that.initValue.partakeInstName = e.instName
				_that.expenseCategoryId = e.expenseCategoryId
				_that.expenseCategoryName = e.expenseCategoryName
				_that.serverDate = e.serverDate
				_that.codeMap = JSON.parse(e.codeMap) 
				_that.dvid = e.dvid
				_that.erpProjectBatches = e.erpProjectBatches
				if(e.bxUserId && e.configDataCacheKey){
					uni.getStorage({
						key: e.configDataCacheKey,
						success: function(res) {
							//if(res.data && res.data instanceof Array){
							if(res.data && Object.prototype.toString.call(res.data)==='[object Array]'){
								_that.autoformdata = res.data
								Object.assign(_that.initValue, _that.formdata)
								_that.autoformdata[0].order = _that.order
								
								_that.filterIdList = _that.datas.filter((e,i)=>{
									return (i != _that.index)
								}).map(e=>e.payApplicationFormDataShowId).join(",")
								_that.payApplicationFormDataShowId = _that.formdata.payApplicationFormDataShowId
								changeEditor(_that.autoformdata[0].editors, "payApplicationFormDataShowId","link","../../public/pageSearch/pageSearch")
								changeEditor(_that.autoformdata[0].editors, "payApplicationFormDataShowId", "linkParam", {
									other:JSON.stringify({
										firstId: _that.payApplicationFormDataShowId,
										filterIdList: _that.filterIdList,
										invoiceNumber: _that.invoiceNumber,
										userId: _that.bxUserId
									}),
									namefield:"onlyCode",
									notefield:"userName",
									extrafield:"payNum",
									searchfield:"q",
									initload:true,
									url:"payApplicationFormShow/findUnReimbursementPage",
									cachename:_that.payApplicationFormDataShowIdCacheKey,
									placeholder:"请输入关键字查询",
								})
								changeEditor(_that.autoformdata[0].editors, "userId","link","../../public/pageSearch/pageSearch")
								changeEditor(_that.autoformdata[0].editors, "userId", "linkParam", {
									other:JSON.stringify({
										containLeaveFlag: true,
									}),
									namefield:"username",
									notefield:"posInstName",
									searchfield:"q",
									initload:true,
									url:"temployee/getStaffCombogrid",
									cachename:_that.userIdCacheKey,
									placeholder:"请输入姓名"
								})
								changeEditor(_that.autoformdata[0].editors,"feesAggregatedWayCode",{
									"linkParam":{
										other:JSON.stringify({
											code: _that.codeMap.feesAggregatedWayCode
										}),
										url:"tsysdict/getCombobox",
										cachename:_that.feesAggregatedWayCodeCacheKey,
										initload:true,
										namefield:'dicname'
									}
								})
								changeEditor(_that.autoformdata[0].editors, "partakeInstId","link","../../public/search/search")
								changeEditor(_that.autoformdata[0].editors, "partakeInstId", "linkParam", {
									method:"get",
									namefield:"text",
									// searchfield:"instName",
									initload:true,
									url:"tinstitution/getComboTree",
									cachename:_that.instCacheKey,
									placeholder:"请输入机构名称"
								})
								changeEditor("title2","marketingPlanningProductId",{
									"link":'../../public/search/search',
									"linkParam":{
										other:JSON.stringify({
											firstId:''
										}),
										url:'inventoryCategory/getExistingProductLineAssortment',
										namefield:'name',
										initload:true,
										cachename:_that.marketingPlanningProductCache
									}
								},null,_that.autoformdata)
								changeEditor(_that.autoformdata[0].editors, "businessTravelDataId","link","../../public/pageSearch/pageSearch")
								changeEditor(_that.autoformdata[0].editors, "businessTravelDataId", "linkParam", {
									other:JSON.stringify({
										userId: _that.bxUserId,
										travelExpensesId: _that.dvid,
									}),
									namefield:"businessTravelCode",
									notefield:"cityName|address",
									// extrafield:"planStartTime~planEndTime",
									// extrasplit:"~",
									searchfield:"q",
									initload:true,
									url:"travelExpenses/getBusinessLeaveList",
									cachename:_that.businessformCacheKey,
									placeholder:"请输入关键字查询",
									method:'post'
								})
								changeEditor(_that.autoformdata[0].editors, "researchDevelopmentId","link","../../public/pageSearch/pageSearch")
								changeEditor(_that.autoformdata[0].editors, "researchDevelopmentId", "linkParam", {
									namefield:"projectName",
									notefield:"projectCode",
									extrafield:"typeName",
									searchfield:"search",
									initload:true,
									url:"createProjectShow/findCreateProjectShowPage",
									cachename:_that.researchDevelopmentIdCacheKey,
									placeholder:"请输入关键字查询",
								})
								changeEditor(_that.autoformdata[0].editors, "businessOpportunityId","link","../../public/pageSearch/pageSearch")
								changeEditor(_that.autoformdata[0].editors, "businessOpportunityId", "linkParam", {
									namefield:"biddingProjectName",
									notefield:"biddingCode",
									searchfield:"q",
									initload:true,
									url:"biddingProject/getBidding",
									cachename:_that.businessOpportunityIdCacheKey,
									placeholder:"请输入关键字查询",
								})
								changeEditor(_that.autoformdata[0].editors, "saleOrderId","link","../../public/pageSearch/pageSearch")
								changeEditor(_that.autoformdata[0].editors, "saleOrderId", "linkParam", {
									namefield:"customerRequirementCode",
									notefield:"customerNameX",
									searchfield:"search",
									initload:true,
									url:"customerRequirementShow/getHeaderDataToDelivery",
									cachename:_that.saleOrderIdCacheKey,
									placeholder:"请输入关键字查询",
								})
								changeEditor(_that.autoformdata[0].editors, "newProductId","link","../../public/pageSearch/pageSearch")
								changeEditor(_that.autoformdata[0].editors, "newProductId", "linkParam", {
									namefield:"newProductName",
									notefield:"newProductStd",
									searchfield:"q",
									initload:true,
									url:"productShowSecond/getProductPage",
									cachename:_that.newProductIdCacheKey,
									placeholder:"请输入关键字查询",
								})
								
								// changeEditor(_that.autoformdata[0].editors, "startTime","endField","endTime")
								// changeEditor(_that.autoformdata[0].editors, "endTime","startField","startTime")
								// changeEditor(_that.autoformdata[0].editors, "endTime","max", getDateStr(new Date()))
								if(!_that.formdata.erpProjectBatches){
									changeEditor('title2', 'erpProjectBatches', {
										defaultName:_that.erpProjectBatches,
										defaultValue:_that.erpProjectBatches 
									},null,_that.autoformdata)
								}
								changeEditor(_that.autoformdata[0].editors, "fileList", "fileUploadKey", "126")
								if(_that.formdata.fileList) {
									var tempFileList = []
									var fileUrlList = _that.formdata.fileList.map(t=>{
										tempFileList.push(t.fileSaveName)
										return t.fileSaveName
									})
									changeEditor(_that.autoformdata[0].editors, "fileList", "fileUrlList", fileUrlList)
									changeEditor(_that.autoformdata[0].editors, "fileList", "tempFileList", tempFileList)
								}
								changeEditor("title2","feesAggregatedWayIds",{
									"linkParam":{
										other:JSON.stringify({
											code:'40346'
										}),
										url:'tsysdict/getComboTree',
										namefield:'text',
										initload:true,
										cachename:_that.feesAggregatedWayCache
									}
								},null,_that.autoformdata)
								if(_that.formdata.feesAggregatedWayIds){
									let idArr = _that.formdata.feesAggregatedWayIds.split(",")
									let nameArr = _that.formdata.feesAggregatedWayName.split(",")
									let feesAggregatedWayList = []
									for(let index in idArr){
										let obj = {
											id:idArr[index],
											text:nameArr[index]
										}
										feesAggregatedWayList.push(obj)
									}
									changeEditor('title2', 'feesAggregatedWayIds', {
										initSelect: feesAggregatedWayList
									},null,_that.autoformdata)
								}else{
									uni.getStorage({
										key:_that.setDataCacheKey,
										success:(res)=>{
											if(res.data){
												let d = res.data
												let idArr = d.feesAggregatedWayIds.split(",")
												let nameArr = d.feesAggregatedWayName.split(",")
												let feesAggregatedWayList = []
												for(let index in idArr){
													let obj = {
														id:idArr[index],
														text:nameArr[index]
													}
													feesAggregatedWayList.push(obj)
												}
												changeEditor('title2', 'feesAggregatedWayIds', {
													initSelect: feesAggregatedWayList
												},null,_that.autoformdata)
												changeEditor('title2', 'feesAggregatedWayIds', {
													defaultName:d.feesAggregatedWayName,
													defaultValue: d.feesAggregatedWayIds
												},null,_that.autoformdata)
											}
										}
									})
								}
								_that.initLoad()
								_that.$nextTick(function(){
									if(_that.$refs.autoform.formdata.feesAggregatedWayCode){
										let objArr = []
										let ids = _that.$refs.autoform.formdata.feesAggregatedWayCode.split(",")
										let names = _that.$refs.autoform.formdata.feesAggregatedWayName.split(",")
										for(let index in ids){
											let obj = {
												code:ids[index],
												dicname:names[index]
											}
											objArr.push(obj)
										}
										_that.$refs.autoform.changeEditor("title2", "feesAggregatedWayCode","type","multilinkbox")
										_that.$refs.autoform.changeEditor('title2', 'feesAggregatedWayCode', {
											initSelect: objArr
										})
										if(ids.indexOf('40392') > -1){
											_that.$refs.autoform.changeEditor("title2", "partakeUserId", "required", true)
										}else{
											_that.$refs.autoform.changeEditor("title2", "partakeUserId", "required", false)
										}
									}else{
										_that.$refs.autoform.changeEditor("title2", "feesAggregatedWayCode","type","labelbox")
										_that.$refs.autoform.changeEditor("title2", "partakeUserId", "required", false)
									}
								})
							}
						}
					});
				}
			})
		},
		onShow() {
			let _that = this
			if(_that.$refs.autoform){
				uni.getStorage({
					key: _that.instCacheKey,
					success: function(res) {
						if(res.data){
							let d = res.data
							var formdata  = _that.$refs.autoform.formdata
							formdata.partakeInstId = d.id
							formdata.partakeInstName = d.text
							_that.instId = d.id
							_that.$refs.autoform.changeEditor("title2", "feesAggregatedWayCode","type","multilinkbox")
							uni.removeStorage({
								key: _that.instCacheKey
							});
						}
					}
				});
				uni.getStorage({
					key: _that.businessformCacheKey,
					success: function(res) {
						if(res.data){
							let d = res.data
							var formdata  = _that.$refs.autoform.formdata
							formdata.businessTravelId = d.businessTravelId;
							formdata.businessTravelDataId = d.businessTravelDataId;
							formdata.businessTravelCode = d.businessTravelCode;
							formdata.planStartTime = d.planStartTime;
							formdata.planEndTime = d.planEndTime;
							formdata.startTime = d.planStartTime;
							formdata.endTime = d.endTime;
							formdata.cityName = d.cityName;
							formdata.address = d.address;
							formdata.vehicleTypeId = d.vehicleTypeId;
							formdata.vehicleTypeName = d.vehicleTypeName;
							_that.$refs.autoform.initSelectIndex("title2", "vehicleTypeId")
							formdata.partakeInstId = _that.instId;
							formdata.partakeInstName = _that.instName;
							if(_that.instId){
								_that.$refs.autoform.changeEditor("title2", "feesAggregatedWayCode","type","multilinkbox")
							}else{
								_that.$refs.autoform.changeEditor("title2", "feesAggregatedWayCode","type","labelbox")
							}
							uni.removeStorage({
								key: _that.businessformCacheKey
							});
						}
					}
				});
				uni.getStorage({
					key: _that.feesAggregatedWayCodeCacheKey,
					success: function(res) {
						if(res.data){
							let d = res.data
							var formdata  = _that.$refs.autoform.formdata
							formdata.feesAggregatedWayCode = d.map(e=>e.code).join(',')
							formdata.feesAggregatedWayName = d.map(e=>e.dicname).join(',')
							_that.$refs.autoform.changeEditor('title2', 'feesAggregatedWayCode', {
								initSelect: d
							})
							let sz = formdata.feesAggregatedWayCode.split(',')
							if(sz.indexOf('40392') > -1){
								_that.$refs.autoform.changeEditor("title2", "partakeUserId", "required", true)
							}else{
								_that.$refs.autoform.changeEditor("title2", "partakeUserId", "required", false)
							}
							uni.removeStorage({
								key: _that.feesAggregatedWayCodeCacheKey
							});
						}
					}
				});
				uni.getStorage({
					key: _that.researchDevelopmentIdCacheKey,
					success: function(res) {
						if(res.data){
							let d = res.data
							var formdata  = _that.$refs.autoform.formdata
							formdata.researchDevelopmentId = d.id
							formdata.researchDevelopmentName = d.projectName
							formdata.researchDevelopmentCode = d.projectCode
							uni.removeStorage({
								key: _that.researchDevelopmentIdCacheKey
							});
						}
					}
				});
				uni.getStorage({
					key: _that.businessOpportunityIdCacheKey,
					success: function(res) {
						if(res.data){
							let d = res.data
							var formdata  = _that.$refs.autoform.formdata
							formdata.businessOpportunityId = d.id
							formdata.businessOpportunityName = d.biddingProjectName
							formdata.businessOpportunityCode = d.biddingCode
							uni.removeStorage({
								key: _that.businessOpportunityIdCacheKey
							});
						}
					}
				});
				uni.getStorage({
					key: _that.saleOrderIdCacheKey,
					success: function(res) {
						if(res.data){
							let d = res.data
							var formdata  = _that.$refs.autoform.formdata
							formdata.saleOrderId = d.customerRequirementId
							formdata.saleOrderCode = d.customerRequirementCode
							uni.removeStorage({
								key: _that.saleOrderIdCacheKey
							});
						}
					}
				});
				uni.getStorage({
					key: _that.newProductIdCacheKey,
					success: function(res) {
						if(res.data){
							let d = res.data
							var formdata  = _that.$refs.autoform.formdata
							formdata.newProductId = d.id
							formdata.newProductCode = d.newProductCode
							uni.removeStorage({
								key: _that.newProductIdCacheKey
							});
						}
					}
				});
				uni.getStorage({
					key: _that.payApplicationFormDataShowIdCacheKey,
					success: function(res) {
						if(res.data){
							let d = res.data
							var formdata  = _that.$refs.autoform.formdata
							_that.payApplicationFormDataShowId = d.id
							formdata.payApplicationFormDataShowId = d.id
							formdata.payApplicationFormCode = d.onlyCode
							if(d.invoiceNumber){
								formdata.invoiceNumber = d.invoiceNumber
							}
							formdata.userId = d.userId
							formdata.userName = d.userName
							formdata.posId = d.posId
							formdata.posName = d.posName
							formdata.instId = d.instId
							formdata.instName = d.instName
							formdata.remark = d.joinRemark
							formdata.paidNum = d.payNum
							formdata.payeeName = d.payeeName
							formdata.planPayNum = ""
							formdata.applyPayNum = ""
							formdata.selfPayNum = ""
							formdata.taxRate = d.taxRate
							formdata.itemCode = d.itemCode
							formdata.itemName = d.itemName
							formdata.itemType = d.itemType
							formdata.accountId = d.accountId
							formdata.accountName = d.accountName
							formdata.partakeInstId = _that.instId;
							formdata.partakeInstName = _that.instName;
							_that.$refs.autoform.changeEditor("title2", "paidNum","type","labelbox")
							uni.removeStorage({
								key: _that.payApplicationFormDataShowIdCacheKey
							});
						}
					}
				});
				uni.getStorage({
					key: _that.userIdCacheKey,
					success: function(res) {
						if(res.data){
							let d = res.data
							var formdata  = _that.$refs.autoform.formdata
							formdata.userId = d.id
							formdata.userName = d.username
							if(d.id ==_that.bxUserId){
								formdata.posId = _that.posId
								formdata.posName = _that.postName
								formdata.instId =  _that.instId
								formdata.instName = _that.instName
								formdata.partakeInstId = _that.instId
								formdata.partakeInstName = _that.instName
							}else{
								formdata.posId = d.salaryPosId
								formdata.posName = d.salaryPosName
								formdata.instId = d.salaryPosInstId
								formdata.instName = d.salaryPosInstName
								formdata.partakeInstId = d.salaryPosInstId
								formdata.partakeInstName = d.salaryPosInstName
							}
							uni.removeStorage({
								key: _that.userIdCacheKey
							});
						}
					}
				});
				uni.getStorage({
					key: _that.feesAggregatedWayCache, 
					success: function(res) {
						if(res.data){
							let d = res.data
							var formdata  = _that.$refs.autoform.formdata
							formdata.feesAggregatedWayIds = d.map(e=> e.id).join(',')
							formdata.feesAggregatedWayName = d.map(e=> e.text).join(',')
							_that.$refs.autoform.changeEditor('title2', 'feesAggregatedWayIds', {
								initSelect: d
							})
							uni.removeStorage({
								key: _that.feesAggregatedWayCache
							});
						}
					}
				});
				uni.getStorage({
					key:_that.partakeUserCache,
					success:(res)=>{
						if(res.data){
							let d = res.data
							let formdata = _that.$refs.autoform.formdata
							formdata.partakeUserId = d.id
							formdata.partakeUserName = d.username
						}
						uni.removeStorage({
							key:_that.partakeUserCache
						})
					}
				})
				uni.getStorage({
					key:_that.marketingPlanningProductCache,
					success:(res)=>{
						if(res.data){
							let d = res.data
							let formdata = _that.$refs.autoform.formdata
							formdata.marketingPlanningProductId = d.id
							formdata.marketingPlanningProductName = d.name
						}
						uni.removeStorage({
							key:_that.marketingPlanningProductCache
						})
					}
				})
			}
		}
	}
</script>

<style>

</style>                                          